package com.itheima.redbaby.activity;


import com.itheima.redbaby.BaseActivity;
import com.itheima.redbaby.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;

public class YouHuiKaActivity extends BaseActivity implements OnClickListener {
	private RelativeLayout youhuika_first_rel;
	private RelativeLayout youhuika_second_rel;
	private RelativeLayout youhuika_thrid_rel;
	private ImageView youhuika_first_img;
	private ImageView youhuika_second_img;
	private ImageView youhuika_thrid_img;
	private int type=0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.gift_card_activity);
		init();
	}
	private void init() {
		youhuika_first_rel = (RelativeLayout) findViewById(R.id.youhuika_first_rel);
		youhuika_second_rel = (RelativeLayout) findViewById(R.id.youhuika_second_rel);
		youhuika_thrid_rel = (RelativeLayout) findViewById(R.id.youhuika_thrid_rel);
		
		youhuika_first_rel.setOnClickListener(this);
		youhuika_second_rel.setOnClickListener(this);
		youhuika_thrid_rel.setOnClickListener(this);
		
		 youhuika_first_img = (ImageView)findViewById(R.id.youhuika_first_img);
		 youhuika_second_img = (ImageView)findViewById(R.id.youhuika_second_img);
		 youhuika_thrid_img = (ImageView)findViewById(R.id.youhuika_thrid_img);
	}
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.youhuika_second_rel:
			showView(youhuika_second_img);
			hideView(youhuika_first_img);
			hideView(youhuika_thrid_img);
			type=2;
			checkOutData.putExtra("type", type);
			setResult(Activity.RESULT_OK, checkOutData);
			finish();
			break;
		case R.id.youhuika_first_rel:
			showView(youhuika_first_img);
			hideView(youhuika_second_img);
			hideView(youhuika_thrid_img);
			type=1;
			checkOutData.putExtra("type", type);
			setResult(Activity.RESULT_OK, checkOutData);
			finish();
			break;
		case R.id.youhuika_thrid_rel:
			showView(youhuika_thrid_img);
			hideView(youhuika_second_img);
			hideView(youhuika_first_img);
			type=3;
			checkOutData.putExtra("type", type);
			setResult(Activity.RESULT_OK, checkOutData);
			finish();
			break;
		}
	}
	@Override
	public void onBackPressed() {
		checkOutData.putExtra("type", type);
		setResult(Activity.RESULT_OK, checkOutData);
		finish();
	}
}
